#!/usr/bin/env python3
# -*- coding:utf-8 -*-
####################################################################################################
# File: cmd.py                                                                                     #
# Created Date: Sunday, August 15th 2021, 1:12:19 am                                               #
# Author: Zongliang Hou                                                                            #
# E-mail: EnderZ@sjtu.edu.cn                                                                       #
# Copyright (c) 2021 Lei Lab                                                                       #
####################################################################################################


import argparse
import sys
sys.path.append("/Users/ender/Code_repo/rosalind-brush-questions")
from utils import read_fasta


parser = argparse.ArgumentParser()
parser.add_argument('-f', '--fasta', type=str, help='DNA sequence file')
args = parser.parse_args()


def count_GC(seq: str):
    seq = seq.upper()
    seq_len = len(seq)
    gc = seq.count('G') + seq.count('C')
    return gc / seq_len * 100


seqs = read_fasta(args.fasta)
seqs_gc = {k: count_GC(v) for k, v in seqs.items()}

max_gc_seq = None
for k, v in seqs_gc.items():
    if (not max_gc_seq) or seqs_gc[max_gc_seq] < v:
        max_gc_seq = k

print(max_gc_seq)
print(seqs_gc[max_gc_seq])
